﻿using System.Management.Instrumentation;
using SportStore.Data;
using SportStore.Model;

namespace SportStore.Services
{
    /// <summary>
    /// Implements the product service.
    /// </summary>
    public class ProductService : IProductService
    {
        /// <summary>
        /// Gets or sets the product repository.
        /// </summary>
        public IProductRepository ProductRepository { get; set; }

        /// <summary>
        /// Gets the product.
        /// </summary>
        public Product GetProduct(int productId)
        {
            var product = this.ProductRepository.GetById(productId);

            if (product == null)
            {
                throw new InstanceNotFoundException(string.Format("Product id: {0}", productId));
            }

            return product;
        }
    }
}
